package com.haust.dianqi.web.admin;

import com.haust.dianqi.pojo.Article;
import com.haust.dianqi.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Auther: csp1999
 * @Date: 2020/10/10/14:30
 * @Description: 管理员操作
 */
@Controller
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private ArticleService articleService;

    @PostMapping("/addArticle")
    public String addArticle(Article article, Model model){
        System.out.println("aaaaaa");
        Article addResult = articleService.addArticle(article);
//        String fileId = article.getFileId();
        String articleId = addResult.getId();

        model.addAttribute("msg","文章添加成功！");
        model.addAttribute("articleId",articleId);
        return "/admin/success";
    }

    @GetMapping("/updateArticle")
    public String updateArticle(){


        return "";
    }

    @PostMapping("/deleteArticle")
    public String deleteArticle(){


        return "";
    }
}
